$package('itsm.system');

itsm.system.investmentLevelMain=function(){
	this.opt='';
	return {
		//列表
		investmentLevelMainGrid:function(){
			var params = $.extend({},jqGridParams, {	
				url:'investmentLevel!findInvestmentLevelPager.action',
				caption:'投资级别列表',
				colNames:['ID','投资级别','投资资金','会员单数','购股比例','追加资金','直推奖金','对碰奖金','对碰封顶','动态分配','累计购股额'],
			 	colModel:[
			 	          {name:'investmentLevelId',align:'center'},
			 	          {name:'levelName',align:'center'},
			 	          {name:'investmentFunds',align:'center'},
			 	          {name:'memberOrderNum',align:'center'},
			 	          {name:'proportion',align:'center'},
			 	          {name:'anAdd',align:'center'},
			 	          {name:'recommend',align:'center'},
			 	          {name:'ontouch',align:'center'},
			 	          {name:'ontouchCap',align:'center'},
			 	          {name:'dynamicAssign',align:'center'},
			 	          {name:'totalShareSum',align:'center'}
			 	],
				jsonReader: $.extend(jqGridJsonReader, {id: "investmentLevelId"}),
				sortname:'investmentLevelId',
				pager:'#investmentLevelMainPager'
				});
				$("#investmentLevelMainGrid").jqGrid(params);
				$("#investmentLevelMainGrid").navGrid('#investmentLevelMainPager',navGridParams);
				//列表操作项
				$("#t_investmentLevelMainGrid").css(jqGridTopStyles);
				$("#t_investmentLevelMainGrid").html($('#investmentLevelMainGridToolbar').html());
				
				//自适应宽度
				setGridWidth("#investmentLevelMainGrid","regCenter",10);
		},
		//打开添加窗口
		openAddWin:function(){
			opt='saveInvestmentLevel';
			resetForm('#investmentLevelMain_add_form');
			$('#investmentLevelMain_add_win').window('open');
		},
		
		//打开编辑窗口
		openEditWin:function(){
			opt='editInvestmentLevel';
			checkBeforeEditGrid('#investmentLevelMainGrid',function(rowData){
				$.post('investmentLevel!findInvestmentLevelInfo.action','ilDTO.investmentLevelId='+rowData.investmentLevelId,function(data){
					$('#investmentLevelMain_investmentLevelId').val(data.investmentLevelId);
					$('#investmentLevelMain_levelName').val(data.levelName);
					$('#investmentLevelMain_investmentFunds').val(data.investmentFunds);
					$('#investmentLevelMain_memberOrderNum').val(data.memberOrderNum);
					$('#investmentLevelMain_proportion').val(data.proportion);
					$('#investmentLevelMain_anAdd').val(data.anAdd);
					$('#investmentLevelMain_recommend').val(data.recommend);
					$('#investmentLevelMain_ontouch').val(data.ontouch);
					$('#investmentLevelMain_ontouchCap').val(data.ontouchCap);
					$('#investmentLevelMain_dynamicAssign').val(data.dynamicAssign);
					$('#investmentLevelMain_totalShareSum').val(data.totalShareSum);
				});
				$('#investmentLevelMain_add_win').window('open');
			});	
		},
		
		//保存
		saveInvestmentLevel:function(){
			if($('#investmentLevelMain_add_win').form('validate')){
				var _param = $('#investmentLevelMain_add_win form').serialize();
				$.post('investmentLevel!'+opt+'.action',_param,function(data){
					msgShow('保存成功!','show');
					$('#investmentLevelMain_add_win').window('close');
					$('#investmentLevelMainGrid').trigger('reloadGrid');
				})
				
			}
		},
		//删除
		deleteInvestmentLevel:function(){
			checkBeforeDeleteGrid('#investmentLevelMainGrid',function(rowIds){
				var pp = $.param({'ids':rowIds},true);
				$.post("investmentLevel!deleteInvestmentLevel.action", pp, function(){
					$('#investmentLevelMainGrid').trigger('reloadGrid');
					msgShow('删除成功!','show');
				}, "json");
			});
		},
		init:function(){
			itsm.system.investmentLevelMain.investmentLevelMainGrid();
		}
	}
	
}();

$(function(){
	itsm.system.investmentLevelMain.init();
});